package userApi

import (
	"chart.zozoo.net/app/service/userService"
	"chart.zozoo.net/app/utils/rsp"
	"github.com/gin-gonic/gin"
)

func Login(c *gin.Context) {
	p := new(userService.RegisterParams)
	if err := c.ShouldBindJSON(p); err != nil {
		rsp.JsonErr(c, rsp.SetMsg(err.Error()))
		return
	}

	token, err := userService.Login(p)
	if err != nil {
		rsp.JsonErr(c, rsp.SetMsg(err.Error()))
		return
	}

	rsp.JsonOk(c, rsp.SetData(map[string]interface{}{"token": token}))
}
